<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods', function (Blueprint $table) {
            $table->id();
            $table->integer('store_id')->unsigned()->default(0)->comment('店铺id');
            $table->integer('good_type_id')->unsigned()->default(0)->comment('商品分类id');
            $table->tinyInteger('sale_type')->default(1)->comment('普通1，热销2，店长推荐3，新品4');
            $table->string('title', 100)->default('')->comment('商品名称');
            $table->string('cover', 100)->default('')->comment('商品封面');
            $table->string('describe', 255)->default('')->comment('商品描述');
            $table->text('detail')->comment('商品详情');
            $table->string('sku', 255)->default('')->comment('商品规格，如40粒一瓶');
            $table->integer('base_price')->unsigned()->default(0)->comment('商品零售价，单位分');
            $table->integer('weight')->unsigned()->default(0)->comment('重量，单位克');
            $table->tinyInteger('status')->default(1)->comment('商品状态，1上架，2下架，3售罄');
            $table->integer('jf')->unsigned()->default(0)->comment('单品可抵扣积分上限(分)');
            $table->integer('jf_send')->unsigned()->default(0)->comment('单品可得积分(分)');
            $table->integer('share_money')->unsigned()->default(0)->comment('奖金来源是商品时，分润数额，单位分');
            $table->integer('cost')->unsigned()->default(0)->comment('奖金池计算时的设定成本');
            $table->integer('sort')->unsigned()->default(0)->comment('排序 , 越大越优先');
            $table->integer('is_delivery_fee')->unsigned()->default(1)->comment('包邮 1 ; 不包邮 2 ; 不包邮 且 分单 3 ;  不包邮 且 此商品单独算一单 4\n包邮 : 不分单, 只按照重量和地区计算\n分单 : 不足一单与其他商品算一单 , 达到分单数算一单 , 剩余仍与其他商品算一单\n单独算一单 : 不足一单单独算一单 , 达到分单数 算一单 , 剩余的又算一单 ');
            $table->integer('list_num')->unsigned()->default(0)->comment('该商品多少个算一个运单 默认 0 , 无分单数目');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `goods` comment '商品表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods');
    }
}
